package war2100.editor.menu.handler;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JOptionPane;

import war2100.Editor;

public class NewHandler implements ActionListener {
	private Editor editor;

	public NewHandler(Editor editor) {
		this.editor = editor;
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		int n = 1;
		
		if (editor.isMapIsModified() == true) {
			String[] yesNoOptions = { "Ja", "Nein" };
	
			n = JOptionPane.showOptionDialog(null, "Neue Welt erstellen und aktuelle verwerfen?", "Neue Welt erstellen", JOptionPane.YES_NO_CANCEL_OPTION,
					JOptionPane.QUESTION_MESSAGE, null, yesNoOptions, yesNoOptions[0]);
		}
	
		if (editor.isMapIsModified() == false || n == JOptionPane.YES_OPTION) {
			editor.newWorld();
		}

	}

}
